<?php

namespace App\Recharge\Bean;

use App\Basic\Bean;
use App\Models\InterfaceConfiguration;
use Illuminate\Http\Request;

class ApiNotifyDataBean extends Bean
{
    /**
     * @var string
     */
    protected string $order_no = "";

    /**
     * @var mixed
     */
    protected mixed $state = "";

    /**
     * @var bool 是否往下执行成功或失败操作
     */
    protected bool $execute = false;

    /**
     * @var bool 是否充值成功
     */
    protected bool $rechargeSuccess = false;

    /**
     * @var string
     */
    protected string $rechargeErrorMessage = '充值失败';

    /**
     * @var Request|null
     */
    protected ?Request $request = null;

    /**
     * @var string
     */
    protected string $cami = '';

    /**
     * @var bool 是否是订单号 不是的话为第三方订单号
     */
    protected bool $isOrderNo = true;

    /**
     * @var InterfaceConfiguration|null
     */
    protected ?InterfaceConfiguration $api = null;

    /**
     * @return string
     */
    public function getOrderNo(): string
    {
        return $this->order_no;
    }

    /**
     * @param string $order_no
     * @return ApiNotifyDataBean
     */
    public function setOrderNo(string $order_no): static
    {
        $this->order_no = $order_no;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getState(): mixed
    {
        return $this->state;
    }

    /**
     * @param int|string $state
     * @return ApiNotifyDataBean
     */
    public function setState(mixed $state): static
    {
        $this->state = $state;
        return $this;
    }

    /**
     * @return bool
     */
    public function isExecute(): bool
    {
        return $this->execute;
    }

    /**
     * @param bool $execute
     * @return ApiNotifyDataBean
     */
    public function setExecute(bool $execute): static
    {
        $this->execute = $execute;
        return $this;
    }

    /**
     * @return bool
     */
    public function isRechargeSuccess(): bool
    {
        return $this->rechargeSuccess;
    }

    /**
     * @param bool $rechargeSuccess
     * @return ApiNotifyDataBean
     */
    public function setRechargeSuccess(bool $rechargeSuccess): static
    {
        $this->rechargeSuccess = $rechargeSuccess;
        return $this;
    }

    /**
     * @return bool
     */
    public function isOrderNo(): bool
    {
        return $this->isOrderNo;
    }

    /**
     * @param array $array
     * @return string
     */
    public function getOrderNoKey(array $array = []): string
    {
        if (empty($array) || count($array) != 2) {
            $array = ['order_sn', 'api_trade_no'];
        }
        return $this->isOrderNo() ? $array[0] : $array[1];
    }

    /**
     * @param bool $isOrderNo
     * @return static
     */
    public function setIsOrderNo(bool $isOrderNo): static
    {
        $this->isOrderNo = $isOrderNo;
        return $this;
    }

    /**
     * @return InterfaceConfiguration|null
     */
    public function getApi(): ?InterfaceConfiguration
    {
        return $this->api;
    }

    /**
     * @param InterfaceConfiguration|null $api
     * @return static
     */
    public function setApi(?InterfaceConfiguration $api): static
    {
        $this->api = $api;
        return $this;
    }

    /**
     * @return string
     */
    public function getRechargeErrorMessage(): string
    {
        return $this->rechargeErrorMessage;
    }

    /**
     * @param string $rechargeErrorMessage
     * @return static
     */
    public function setRechargeErrorMessage(string $rechargeErrorMessage): static
    {
        $this->rechargeErrorMessage = $rechargeErrorMessage;
        return $this;
    }

    /**
     * @return Request|null
     */
    public function getRequest(): ?Request
    {
        return $this->request;
    }

    /**
     * @param Request|null $request
     * @return self
     */
    public function setRequest(?Request $request): self
    {
        $this->request = $request;
        return $this;
    }

    /**
     * @return string
     */
    public function getCami():string
    {
        return $this->cami;
    }

    /**
     * @param string $cami
     * @return $this
     */
    public function setCami(string $cami): static
    {
        $this->cami = $cami;
        return $this;
    }

}
